home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / unitinfo.swg / 0003_Global Types In UNIT.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  1.1 KB  |  58 lines

  1. {
  2. I am wondering if it is possible to pass a Record Type and File Type to
  3. a Procedure in a Unit where the Record or File Type has not
  4. been declared.  if it can be done I will need a little sample
  5. to get me going.  Thanks in advance.
  6.  
  7. Yes, as long as the Unit With the Procedure Uses the Unit in which the Types
  8. are declared.  That's why it's frequently a good idea to move all your global
  9. Types and Variables to their own little Unit:
  10. }
  11.  
  12. Unit Globals;
  13.  
  14. Interface
  15.  
  16. Type
  17.   tMyRecord = Record
  18.     Name,Address : String[40];
  19.     Zip : String[5];
  20.     { etc.}
  21.   end;
  22.  
  23. Implementation
  24.  
  25. end.  { of Unit Globals }
  26.  
  27.  
  28. Unit LowLevels;
  29.  
  30. Interface
  31.  
  32. Uses Globals;
  33.  
  34. Procedure GetMyRecord(Var ThisRecord : tMyRecord);
  35.  
  36. Implementation
  37.  
  38. Procedure GetMyRecord(Var ThisRecord : tMyRecord); begin
  39.   { whatever }
  40. end;
  41.  
  42. end. { of Unit LowLevels }
  43.  
  44.  
  45. Program  WhatEver;
  46.  
  47. Uses Globals, LowLevels;
  48.  
  49. Var
  50.   MainRecord : tMyRecord;
  51.   { depending on a lot of things, you might want to declare this
  52.     Variable in the Unit Globals, rather than here }
  53.  
  54. begin
  55.   GetMyRecord(MainRecord);
  56. end.
  57.  
  58.